/*
 * Copyright 2020 edenrun.cn All right reserved. This software is the
 * confidential and proprietary information ofedenrun.cn ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with edenrun.cn.
 */

package com.zoom.pluto.openapi.controller;

import com.zoom.pluto.common.model.dto.HealthInfoDTO;
import com.zoom.pluto.common.model.dto.Result;
import com.zoom.pluto.openapi.service.impl.OpenApiServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 对外开放平台控制层
 *
 * @author zoom
 * @date 2020-06-28
 */

@CrossOrigin(origins = "*", allowedHeaders = "*", maxAge = 3600)
@RestController
@Api(value = "健康指标统一查询", tags = {"健康指标统一查询"})
public class OpenApiController {

    @Resource
    private OpenApiServiceImpl openApiService;

    @ApiOperation(value = "根据身份证号取得患者最新检查结果，骨密度：31030110519581130849；心血管：3101051994904080428", httpMethod = "GET")
    @GetMapping(value = "/openapi/healthInfo/query/{idno}")
    public Result<HealthInfoDTO> querySmfDetailByPatNo(@PathVariable String idno) {
        HealthInfoDTO healthInfoDTO = new HealthInfoDTO();
        healthInfoDTO.setIdNo(idno);
        healthInfoDTO.setZxgDTO(openApiService.getLastZxgInfo(idno));
        healthInfoDTO.setSmartDTO(openApiService.getLastSmartInfo(idno));
        healthInfoDTO.setSmfDTO(openApiService.getLastSmfInfo(idno));
        return Result.success(healthInfoDTO);
    }

}
